<template>
  <div class="profile">
    <!-- 顶部导航栏 -->
    <cate-nav-bar class='prof-nav-bar'>
      <div slot='center'>我的档案</div>
    </cate-nav-bar>
    <!-- 用户登录/注册信息展示 -->
    <user-info @loginClick='LoginClick' :userInfo='user' />
    <!-- 用户账号余额信息展示 -->
    <account-info />
    <!-- 操作信息展示 -->
    <normal-list-view 
      :list-data='orderList'
    />
    <normal-list-view 
      :list-data='serviceList'
    />
  </div>
</template>

<script>
import cateNavBar from 'components/common/navbar/NavBar.vue'

import userInfo from './childComps/UserInfo.vue'
import accountInfo from './childComps/AccountInfo.vue'
import NormalListView from './childComps/NormalListView.vue'

import {CLEARUSERINFO} from 'store/mutaions-types'

// 导入映射 辅助函数
import { mapGetters} from 'vuex'

export default {
  name: 'Profile',
  components:{
    cateNavBar,
    userInfo,
    accountInfo,
    NormalListView
  },
  data(){
    return {
      orderList: [
        {icon: 'message.svg', info: '我的消息'},
        {icon: 'pointer.svg', info: '积分商城'},
        {icon: 'vip.svg', info: '会员卡'},
      ],
      serviceList: [
        {icon: 'cart.svg', info: '我的购物车'},
        {icon: 'shopping.svg', info: '下载购物APP'},
      ]
    }
  },
  created(){

  },
  mounted(){},
  watch:{},
  computed:{
    ...mapGetters({
      user: 'getUserInfo'
    })
  },
  methods:{
    LoginClick() {
      // 先清空登录状态
      this.$store.commit(CLEARUSERINFO, {})
      window.sessionStorage.removeItem('userName')

      // 跳转登录页面
      this.$router.push("/login")
    }
  },
}
</script>
<style scoped>
.profile {
  background: #f2f2f2;
}
.prof-nav-bar {
  background-color: var(--color-tint);
  color: #fff;
}

</style>